package com.lnsf.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.lnsf.entity.Comments;
import com.lnsf.entity.User;

@Transactional
public interface CommentsDao extends CrudRepository<Comments, Integer>{

	
	//Comments findByUserAndBooks(String phone , String password);
	
	@Override
	Iterable<Comments> findAll();
	
	//
	@Override
	<S extends Comments> S save(S arg0);
	
	//查找本用户中某商品的全部评论
	@Query(value="select * from comments where  good_id = ?1 and parent is null ",nativeQuery=true)
	List<Comments> findCommByUserAndGood(int goodid);
	
	@Modifying
	@Query(value="update comments set parent = ?1 where comments_id = ?2",nativeQuery=true)
	int updateComm(int preCommId , int currentCommId);
}
